/*! Copyright (C) 2011 All Rights Reserved
 *! Author : Sebastian Pichelhofer
 *! Description:
-----------------------------------------------------------------------------**
 *!
 *!  This program is free software: you can redistribute it and/or modify
 *!  it under the terms of the GNU General Public License as published by
 *!  the Free Software Foundation, either version 3 of the License, or
 *!  (at your option) any later version.
 *!
 *!  This program is distributed in the hope that it will be useful,
 *!  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *!  GNU General Public License for more details.
 *!
 *!  You should have received a copy of the GNU General Public License
 *!  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *!
 *!  It means that the program's users have the four essential freedoms:
 *!
 *!   * The freedom to run the program, for any purpose (freedom 0).
 *!   * The freedom to study how the program works, and change it to make it do what you wish (freedom 1). Access to the source code is a precondition for this.
 *!   * The freedom to redistribute copies so you can help your neighbor (freedom 2).
 *!   * The freedom to distribute copies of your modified versions to others (freedom 3). By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this.

-----------------------------------------------------------------------------**/
package Chronomotion;

import java.util.ArrayList;

import gnu.io.CommPortIdentifier;

import javax.swing.DefaultListModel;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.border.TitledBorder;
import javax.swing.JButton;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class MainWindow {

	private Chronomotion Parent;

	/**
	 * Create the panel.
	 */
	public MainWindow(Chronomotion parent) {

		Parent = parent;
		// setLayout(null);

		JFrame frame = new JFrame();
		frame.setBounds(10, 106, 554, 401);
		frame.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

		JPanel FastControlPanel = new JPanel();
		FastControlPanel.setBorder(new TitledBorder(null, "Fast Control", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		frame.getContentPane().add(FastControlPanel);
		GridBagLayout gbl_FastControlPanel = new GridBagLayout();
		gbl_FastControlPanel.columnWidths = new int[] { 55, 0, 55, 0 };
		gbl_FastControlPanel.rowHeights = new int[] { 0, 0, 23, 0 };
		gbl_FastControlPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
		gbl_FastControlPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
		FastControlPanel.setLayout(gbl_FastControlPanel);

		JButton btnNewButton = new JButton("UP");
		GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
		gbc_btnNewButton.fill = GridBagConstraints.BOTH;
		gbc_btnNewButton.insets = new Insets(0, 0, 5, 5);
		gbc_btnNewButton.gridx = 1;
		gbc_btnNewButton.gridy = 0;
		FastControlPanel.add(btnNewButton, gbc_btnNewButton);

		JButton btnLeft = new JButton("LEFT");
		GridBagConstraints gbc_btnLeft = new GridBagConstraints();
		gbc_btnLeft.insets = new Insets(0, 0, 5, 5);
		gbc_btnLeft.fill = GridBagConstraints.BOTH;
		gbc_btnLeft.gridx = 0;
		gbc_btnLeft.gridy = 1;
		FastControlPanel.add(btnLeft, gbc_btnLeft);

		JButton btnRight = new JButton("RIGHT");
		GridBagConstraints gbc_btnRight = new GridBagConstraints();
		gbc_btnRight.insets = new Insets(0, 0, 5, 0);
		gbc_btnRight.gridx = 2;
		gbc_btnRight.gridy = 1;
		FastControlPanel.add(btnRight, gbc_btnRight);

		JButton btnDown = new JButton("DOWN");
		GridBagConstraints gbc_btnDown = new GridBagConstraints();
		gbc_btnDown.insets = new Insets(0, 0, 0, 5);
		gbc_btnDown.gridx = 1;
		gbc_btnDown.gridy = 2;
		FastControlPanel.add(btnDown, gbc_btnDown);

		JMenuBar menuBar = new JMenuBar();
		frame.setJMenuBar(menuBar);

		JMenu mnNewMenu = new JMenu("File");
		menuBar.add(mnNewMenu);

		JMenuItem mntmNewMenuItem_1 = new JMenuItem("Connect");
		mntmNewMenuItem_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Parent.GetConnectWindow().Show(true);
			}
		});
		mnNewMenu.add(mntmNewMenuItem_1);

		JMenuItem mntmNewMenuItem_2 = new JMenuItem("Exit");
		mntmNewMenuItem_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		mnNewMenu.add(mntmNewMenuItem_2);

		frame.setVisible(true);

	}



}
